<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>密码修改</title>
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#oldPassword').blur(function() {

			var old = document.getElementById('oldPassword').value;
			validate(old)
		})

		$('#newPassword').blur(function() {

			var new1 = document.getElementById('newPassword').value;
			validate1(new1)
			validate2(new1)
			
		})
		$('#rePassword').blur(function() {

			validate2()
		})
	})
	
	function validate2(new1){
		var re=document.getElementById('rePassword').value;
		if(re==new1){
			document.getElementById('show2').innerHTML="";
			
		}else{
			document.getElementById('show2').innerHTML="两次密码输入不一致!";
			document.getElementById('show2').style.color="red";
		}
		
	}
	
	function validate1(new1) {

		$.ajax({
			type : 'post',
			url : '${pageContext.request.contextPath}/user/validate1.action',
			data : 'new1=' + new1,
			success : function(data) {
				showResult1(data)
			}

		})
	}
	function showResult1(data) {

		if (data == 1) {
			document.getElementById('show1').innerHTML = "与原密码相同";
			document.getElementById('show1').style.color = "red";
		}
		if (data == 2) {
			document.getElementById('show1').innerHTML = "";

		}
	}

	function validate(old) {

		$.ajax({
			type : 'post',
			url : '${pageContext.request.contextPath}/user/validate.action',
			data : 'old=' + old,
			success : function(data) {
				showResult(data)
			}

		})
	}

	function showResult(data) {

		if (data == 1) {
			document.getElementById('show').innerHTML = "";
		}
		if (data == 2) {
			document.getElementById('show').innerHTML = "输入错误";
			document.getElementById('show').style.color = "red";
		}
	}
</script>
</head>
<body>
	<div
		style="width: 700px; height: 300px; border: 1px solid #999; padding: 2px; padding-left: 20px;">
		<h2>密码修改：</h2>
		<form action="${pageContext.request.contextPath}/user/changePasss.action" method="post">
		<p>
			原密码：<input type="text" id="oldPassword"><label id="show"></label>
		</p>
		<p>
			新密码：<input type="text" id="newPassword" name="newPass"><label id="show1"></label>
		</p>
		<p>
			确认密码：<input type="text" id="rePassword"><label id="show2"></label>
		</p>
		<button type="submit">确认</button></form>
	</div>
</body>
</html>